<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/axios.js"></script>
</head>

<body>
    <script>
        function getUserAccount() {
            return axios.get('http://www.httpbin.org/get?username=admin&password=123456');
        }

        function getUserPermissions() {
            return axios.get('http://www.httpbin.org/get?username=yoursister&password=654321');
        }

        /* 实现并发无关联 */
        axios.all(
            /* 一堆并发的axios任务（Promise对象） */
            [getUserAccount(),getUserPermissions()]
        )
            .then(axios.spread(function (...ret) {
                // 两个请求现在都执行完成
                console.log("acct=", ret[0]);
                console.log("perms=", ret[1]);
            }));

    </script>
</body>

</html>